package bancosys.tec.persist.entities.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jmine.tec.persist.annotation.Alias;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.Filters;

import bancosys.tec.component.Documentation;
import bancosys.tec.persist.bussobj.AuthPersistableBusinessObject;

/**
 * Entidade utilizada para teste da issue JTEC-1693
 * 
 * @author lundberg
 */
@Entity
@Filters({ @Filter(name = "authFilter", condition = "auth = :auth") })
@Table(name = "ENTITY_WITH_LAZY_CASCAGE_EAGER_ASSOC")
@Alias(value = "EWLCEA")
@Documentation("JTEC-1693")
@SequenceGenerator(sequenceName = "SEQ_EWLCEA", name = "SEQ_EWLCEA")
public class TroubledAuthorizableEntity extends AuthPersistableBusinessObject {

    private Long id;

    private Papel papel;

    /**
     * @return the id
     */
    @Id
    @GeneratedValue(generator = "SEQ_EWLCEA")
    @Column(name = "COD_EWCEA", nullable = false)
    @Documentation("ID")
    public Long getId() {
        return this.id;
    }

    /**
     * @return the papel
     */
    @ManyToOne
    @Cascade({ CascadeType.ALL, CascadeType.DELETE_ORPHAN })
    @JoinColumn(name = "COD_PAP")
    @Documentation("CODIGO DO PAPEL")
    public Papel getPapel() {
        return this.papel;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param papel the papel to set
     */
    public void setPapel(Papel papel) {
        this.papel = papel;
    }
}
